﻿var FileUpload = {
    Initialize: function () {
        $('.file-upload span input').each(function () {
            $(this).fileupload(
                {
                    forceIframeTransport: true,
                    dataType: "text",
                    done: function (e, data) {
                        var fileUpload = $(this).closest(".file-upload");
                        var url = fileUpload.data("href");
                        fileUpload.find("a").remove();
                        fileUpload.append('<a class="no-link" href="' + url + data.result + '" title="' + data.result + '">Download book</a>');
                        fileUpload.find("input[type=hidden]").val(data.result);
                    },
                    url: $(this).closest("span").data("href"),
                    sequentialUploads: true
                });
        });
    }
};
